#include <stdio.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>

class Test
{
public:
	Test()
	{
	}
	static Test * getInstance()
	{
		if(NULL == instance)
		{
			instance = new Test();
		}
		return instance;
	}
	~Test()
	{
		printf("distruct\n");
		if(instance)
		{
			Test *tmp = instance;
			instance = NULL;
			delete tmp;
			// delete instance;
			// instance = NULL;
		}
	}
	private:
		static Test* instance;
};

Test* Test::instance = NULL;

void xx(int& id)
{
    id = 10;
}

void func(int& id)
{
    xx(id);
}

class my {
public:
    my() {
        printf("class my construction\n");
        this->num_ = new int(2);
    }
    ~my() {
        if (num_) {
            delete num_;
            num_ = nullptr;
        }
        printf("class my destruction\n");
    }

private:
    int * num_;

};

int split_string(const char *str, char delim, std::vector<std::string>& vec) {
    if (!str) return -EINVAL;

    std::stringstream ss;
    ss.str(str);

    std::string item;
    while (std::getline(ss, item, delim))
        vec.push_back(item);

    return 0;
}

int main(int argc, char **argv)
{
/*	typedef int *pint;
	int a = 1;
	const pint b = &a;
	int c = 2;
	*b = 2;
	printf("%lf\n", 1e-6);
	unsigned val1 = 10, val2 = 20;
	int i = -100;
	printf("%u\n", val1 -val2);
	printf("%u\n", val2 -val1);
	printf("%u\n", val2 + i);
	printf("%s\n", u8"和萨达");
	typedef char * pchar;
	char a = 0;
	char c = 1;
	const pchar b = &a;
	*b = 2;
	const int &m = 22;
	int &k = 11;
	Test* test = Test::getInstance();
	Test();
	int a[10] = {0};
	std::cout<<&a[1] - a<<std::endl;
    int id = 0;
    func(id);
    std::cout<<id<<std::endl;
    char buf[20] = "\0";
    snprintf(buf, sizeof(buf), "%s%d", "StressRobot", 1);
    printf("%s\n", buf);
*/
    std::vector<std::string> vec = {"11", "22", "33"};
    std::string ip = "11";
    auto it = std::find_if(vec.begin(), vec.end(), [&ip] (std::string& item) {
        return item == ip;
    });
    if (it == vec.end())
        printf("111111111111111111\n");
    else
        printf("2222222222222222222\n");

    //int ret = split_string(" ,   ", ',', vec);
    //printf("%d %lu\n", ret, vec.size());
    //for (auto& item: vec) {
        //printf("%s\n", item.c_str());
    /*}*/
    std::cout << std::logical_and<bool>()(false, true) << std::endl;
	return 0;
}
